package common

import (
	"fmt"
	"os"
	"path/filepath"
)

var CommonHeader = map[string]string{
	"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
	"Host":       "www.meituan.com",
	"Connection": "keep-alive",
	"Accept":     " */*",
	"Origin":     "https://www.meituan.com",
}

func MergreHeader(h1 map[string]string, h2 map[string]string) map[string]string {
	for k, v := range h1 {
		h2[k] = v
	}
	return h2
}
/**
cate 0 表示营业执照 1 表示餐饮服务
*/
func BuildPathFile(id int,cate int)(path string,err error)  {
	base_path:=fmt.Sprintf("%s/%d","./../meituan_license",id)
	pathSeparator:=string(os.PathSeparator)

	_,err=os.Stat(base_path)
	if err!=nil{
		if !os.IsExist(err){
			err=os.MkdirAll(base_path,0644)
			if err!=nil{
				return
			}
		}

	}
	path=fmt.Sprintf("%s%s%d.jpg",base_path,pathSeparator,cate)
	path,err=filepath.Abs(path)
	return
}
// 判断所给路径文件/文件夹是否存在
func Exists(path string) bool {
	_, err := os.Stat(path)
	if err != nil {
		if os.IsExist(err) {
			return true
		}
		return false
	}
	return true
}



